package com.engr.business.util;

import org.apache.commons.codec.digest.DigestUtils;

import java.util.TreeMap;

/**
 * @program: business
 * @desc: 签名工具类
 * @author: lyx
 * @date: 2019-01-04 17:27
 **/
public class SignUtils {

    public static TreeMap<String,Object> getParam(){
        //ParamDto paramDto = new ParamDto();
        TreeMap<String, Object> treeMap = new TreeMap<>();
        treeMap.put("v_mktid", "0001");
        treeMap.put("v_storeid", "390");
        treeMap.put("v_supid", "000016");
        treeMap.put("v_posid", "1101");
        treeMap.put("v_billnum", "40002052118081400001");
        treeMap.put("v_billdate", "2018/09/30 11:11:11");
        treeMap.put("v_billtype", "1");
        treeMap.put("v_price", 14.9);
        treeMap.put("v_num", 1);
        treeMap.put("v_amount", "14.9");
        treeMap.put("v_paycode", "09");
        treeMap.put("v_oposid", "1101");
        treeMap.put("v_obillnum", "40002052118081400001");
        treeMap.put("v_tenantname", "1712112001990000001");
        treeMap.put("v_tenantpass", "792869015");
        return treeMap;
    }

    public static String getSign(String token,String timeStamp){

        // 进行加密 sign
        String signRec = timeStamp + token;

        // SHA1加密
        String sign = DigestUtils.sha1Hex(signRec);

        return sign;
    }

    /**
     * 获取秒级时间错
     *
     * @return
     */
    public static String getTimeStamp() {
        return String.valueOf(System.currentTimeMillis() / 1000);
    }
}
